<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<title><?php echo ($name); ?></title>
<script src="__APP__/statics/jquery-1.9.1.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="__APP__/statics/css/jNotify.jquery.css" />
<script type="text/javascript" src="__APP__/statics/jNotify.jquery.js"></script>
<style>
 body{font-family:"微软雅黑";font-size:12px;color:#666666;background-color:#F9F9F6}
 *{margin: 0;} 
 a{text-decoration:none}
 img{border:0px}
.cat{background-color:#F9F9F6;margin-left:10px;z-index:0;}
.cat_list:hover{background-color:#fff;}
.title{background:url("__APP__/statics/tbg.gif");font-weight:bold}

#save{text-align:center;border:0;width:100%;height:40px;background-color:#fff;position:fixed;left:0px;bottom:0px;z-index:999;border:1px solid #DFDFDF;background-color:#DFDFDF;padding:5px;height:20px}
</style>

<div class="cat" style="margin-top:10px;">
<form method="POST" action="__GROUP__/Goodsmodel/add">
	<input type="text" name="name" size="20" value="请输入模型的名称">
	<input type="submit" value="添加新模型" name="B1">
</form>
</div>

<div class="cat" style="margin-top:10px;">
<table bordercolor="#DDDFFF" border="1" width="100%" style="border-collapse: collapse" cellpadding="3">
	<tr height="17" align="center">
		<td class="title" width="300">模型名称</td>
		<td class="title" width="80">查看/修改字段</td>
		<td class="title" width="40">删除</td>
		<td class="title">　</td>
	</tr>
<?php if(is_array($model)): $i = 0; $__LIST__ = $model;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$model): $mod = ($i % 2 );++$i;?><tr height="20" bgcolor="#F1F5FA" class="cat_list">
		<td width="300"><input name="mid[]" type="text" value="<?php echo ($model["model_id"]); ?>" style="display:none"><input type="text" name="mname[]" value="<?php echo ($model["model_name"]); ?>"></td>
		<td width="80" align="center"><a href="__URL__/model_list/model_id/<?php echo ($model["model_id"]); ?>"><img src="__APP__/statics/add44.gif"></a></td>
		<td width="40" align="center"><a href="javascript:;" onclick="del(<?php echo ($model["model_id"]); ?>)"><img alt="删除" src="__APP__/statics/icons/icon_delete.gif"></a></td>

		<td></td>
	</tr><?php endforeach; endif; else: echo "" ;endif; ?>
</table>
</div>
<div id="save"><input id="save_m" type="button" value="保存更改"></div>

<script>
$(function(){
    $("#save_m").click(function(){
              var mid=[];
			  $("[name='mid[]']").each(function(){
                     mid.push($(this).val()); 
               }); 
			   var mname=[];
			  $("[name='mname[]']").each(function(){
                     mname.push($(this).val()); 
               }); 
			   $.ajax({
			         type:"POST",
					 url:"__URL__/cg_model",
					 dataType:"html",
					 data:{'mid':mid,'mname':mname},
					 success:function(data){
						location.reload();
					 }
			   })
	})
})

function del(t){
    var id=t;
	if(confirm('你确认删除此模型吗？')) {
		$.ajax({
			 type:"GET",
			 url:"__URL__/del_model",
			 dataType:"json",
			 data:{'id':id},
			 success:function(data){
			 }
		})
		location.reload();
	}
}
</script>